using UnityEngine;
using UnityEngine.UI;

public class TextTips : MonoBehaviour
{
	[SerializeField]
	private Text m_Tips;

	[SerializeField]
	private Animator m_Animator;

	public Rect rect
	{
		get
		{
			RectTransform rectTransform = base.transform as RectTransform;
			Rect result = default(Rect);
			Vector3 localPosition = rectTransform.localPosition;
			result.x = localPosition.x - rectTransform.rect.width * 0.5f;
			Vector3 localPosition2 = rectTransform.localPosition;
			result.y = localPosition2.y - rectTransform.rect.height * 0.5f;
			result.size = rectTransform.rect.size;
			return result;
		}
	}

	public void SetText(string text, Color c, bool stationary = false)
	{
		m_Tips.text = text;
		m_Tips.color = c;
		if (stationary)
		{
			m_Animator.Play("Stationary");
			return;
		}
		Vector3 position = base.transform.localPosition;
		float y = position.y;
		Vector2 size = rect.size;
		position.y = y + size.y * 0.5f;
		position = base.transform.parent.TransformPoint(position);
		position = BaseUIController.GetUICamera().WorldToScreenPoint(position);
		if (position.y > (float)Screen.height)
		{
			m_Animator.Play("MoveDown");
		}
		else
		{
			m_Animator.Play("MoveUp");
		}
	}
}
